#!/usr/bin/env python

"""\
INSTRUCTIONS:

(1) Read in the "dc_metro.png" image and plot it using the "gray" colormap.

(2) Use an averaging filter to "smooth" the image.  Use a "5 point stencil"
    where you average the current pixel with its neighboring pixels:

              0 0 0 0 0 0 0
              0 0 0 x 0 0 0
              0 0 x x x 0 0
              0 0 0 x 0 0 0
              0 0 0 0 0 0 0

Plot the image, the smoothed image, and the difference between the two.

HINT: Check documentation for matplotlib functions "imread" and "imshow".
"""

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.image as mpimg

# +++your code here+++
fig = plt.figure()
fig.add_subplot(1,3,1)
img=mpimg.imread('dc_metro.png')
imgplot = plt.imshow(img,cmap='gray')

fig.add_subplot(1,3,2)
b1 = np.roll(img, 1,axis=0)
b2 = np.roll(img, -1,axis=0)
b3 = np.roll(img, 1,axis=1)
b4 = np.roll(img, -1,axis=1)
a = (img+b1+b2+b3+b4)/5
imgplot = plt.imshow(a,cmap='gray')

fig.add_subplot(1,3,3)
c = img - a
imgplot = plt.imshow(c,cmap='gray')


plt.show()
